#include <iostream>
#include "list.h"
using namespace std;

myList::myList(int size_){
    size = size_;
    amount = 0;
    lista = (int*)malloc(size*sizeof(int));
}

myList::~myList(){
    //cout << "Freeing memory!" << endl;
    free(lista);
}

int myList::getValue(int index){
    if(index < size){
        return lista[index];
    }
    else return 0;
}

void myList::setValue(int index,int value){
    lista[index] = value;
}

void myList::removeValue(int index){
    for(int i=index; i<amount; i++)
        lista[i]=lista[i+1];
    amount--;
}

void myList::insertValue(int index,int value){
    for(int i=amount; i>=index; i--)
        lista[i+1] = lista[i];

    lista[index] = value;
    amount++;
}

